<?php

namespace App\Controller\Mission;


use App\Controller\BaseController;
use App\Request\Mission\ReceiveAwardRequest;
use App\Services\Mission\MissionService;
use Hyperf\Context\Context;
use Hyperf\Di\Annotation\Inject;

class ListController extends BaseController
{
    #[Inject]
    public MissionService $missionService;


    /**
     * Note - 任务列表
     * DateTime 2024/8/13 17:20
     * User Admin
     */
    public function list()
    {
        $userInfo = Context::get('user');
        $uid = $userInfo['id'];
        $sex = $userInfo['sex'];
        $language = Context::get('language');
        $data = $this->missionService->list($uid, $sex, $language);
        return $this->return($data);

    }


    /**
     * Note - 领取任务奖励
     * DateTime 2024/8/14 12:00
     * User Admin
     */
    public function receiveAward(ReceiveAwardRequest $request)
    {
        $params = $this->request->post();
        $request->execute($params);
        $userInfo = Context::get('user');
        $uid = $userInfo['id'];
        $mission = $params['mission_id'];
        $ret = $this->missionService->receiveAward($uid, $mission);
        return $this->return($ret);

    }
}